package cn.edu.neusoft.yuejian_02.model;

import java.util.List;

import cn.edu.neusoft.yuejian_02.bean.ClassBean;
import cn.edu.neusoft.yuejian_02.bean.MasterBean;
import cn.edu.neusoft.yuejian_02.bean.VideoBean;
import cn.edu.neusoft.yuejian_02.listener.RetrofitListener;
import cn.edu.neusoft.yuejian_02.service.ClubService;
import cn.edu.neusoft.yuejian_02.service.MasterService;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by jj on 2017/10/9.
 */

public class ClubModel extends BaseModel{


    public Call ClubList(){
        ClubService service=retrofit.create(ClubService.class);
        return  service.clubList();
      /*  call.enqueue(new Callback<List<ClubBean>>() {
            @Override
            public void onResponse(Call<List<ClubBean>> call, Response<List<ClubBean>> response) {
                List<ClubBean> clubBean =  response.body();
                listener.onSuccess(clubBean);
            }

            @Override
            public void onFailure(Call<List<ClubBean>> call, Throwable t) {

            }
        });*/
    }
    public Call searchClub(String s){
        ClubService service=retrofit.create(ClubService.class);
        return service.search(s);

    }


    public void ClassList(String club_id,final RetrofitListener listener){
        ClubService service=retrofit.create(ClubService.class);
        Call<List<ClassBean>>call =  service.classList(club_id);
        call.enqueue(new Callback<List<ClassBean>>() {
            @Override
            public void onResponse(Call<List<ClassBean>> call, Response<List<ClassBean>> response) {
                List<ClassBean> classBean =  response.body();
                listener.onSuccess(classBean);
            }

            @Override
            public void onFailure(Call<List<ClassBean>> call, Throwable t) {

            }
        });
    }
    public void MasterList(final RetrofitListener listener){
        MasterService service=retrofit.create(MasterService.class);
        Call<List<MasterBean>> call= service.masterList();
        call.enqueue(new Callback<List<MasterBean>>() {
            @Override
            public void onResponse(Call<List<MasterBean>> call, Response<List<MasterBean>> response) {
                List<MasterBean> masterBeen =  response.body();
                listener.onSuccess(masterBeen);
            }

            @Override
            public void onFailure(Call<List<MasterBean>> call, Throwable t) {
                listener.onFail();
            }
        });
    }
    public void VideoList(String cid,final RetrofitListener listener){
        ClubService service=retrofit.create(ClubService.class);
        Call<List<VideoBean>> call = service.getClubVideo(cid);
        call.enqueue(new Callback<List<VideoBean>>() {
            @Override
            public void onResponse(Call<List<VideoBean>> call, Response<List<VideoBean>> response) {
                List<VideoBean> videoBeen =  response.body();
                listener.onSuccess(videoBeen);
            }

            @Override
            public void onFailure(Call<List<VideoBean>> call, Throwable t) {
                listener.onFail();
            }
        });
    }
}
